<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
  <script type="text/javascript">
      var roleTable;
  </script>
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <!-- 当前位置 begin -->
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">角色权限分配</li>
            </ol>
          </div>
        </div>
        <!-- 当前位置 end -->

        <!-- 查询筛选内容 bagin -->
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="col-md-1 col-sm-1 col-xs-1 text-right">
              <label class="control-labe h-form-label" for="name">角色名称：</label>
            </div>
            <div class="col-md-2 col-sm-2 col-xs-2">
              <input class="form-control" id="name" name="name" type="text" value="">
            </div>
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" onclick="RoleManager.search()" type="button"><i class="fa fa-search">&nbsp;&nbsp;</i>查询
              </button>
              <button class="btn btn-default" type="reset"><i class="fa fa-mail-reply">&nbsp;&nbsp;</i>重置</button>
            </div>
          </form>
        </div>

        <!-- 表格 begin -->
        <div class="panel panel-white h-panel">
          <div class="panel-body">
            <table class="table table-striped table-bordered table-hover text-center" id="role_table"
                   style='width:100%'></table>
          </div>
        </div>
        <!-- 表格 end -->
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
  <!-- 新增 end -->
  <!-- end: SUBVIEW SAMPLE CONTENTS -->
</div>
<#include "/common/jslib.html">
<script type="text/javascript">
    $(function () {
        RoleManager = {
            search: function () {
                var queryCond = {
                    name: $("#name").val()
                };
                roleTable.options.queryCond = queryCond;
                var tableId = roleTable.options.tableId;
                $(tableId).DataTable().draw();
            },
            assignSecurity: function (url, name) {
                Jmts.openDialog("assignSecurityId", url, name + "---权限分配", 500, 400, 32);
            }
        }
    });
</script>
<!-- 弹窗下拉 -->
<script type="text/javascript">
    (function () {
        // datatable插件
        roleTable = new mi.datatable({
            tableId: '#role_table',
            headerList: [
                '角色名称',
                '上级角色名称',
                '说明',
                '操作'
            ],
            headerName: [
                'name',
                'parentRoleName',
                'comment',
                'operate'
            ],
            ajaxUrl: '/securityRole/listRole',
            queryCond: function () {

            },
            createdRow: function (row, data, dataIndex) {
                $(row).children('td').eq(0).attr('style',
                    'text-align:left;');
                $(row).children('td').eq(1).attr('style',
                    'text-align:left;');
                $(row).children('td').eq(2).attr('style',
                    'text-align:left;');
            },
            columnDefs: [],
            dataSrc: function (data) {
                var newArr = [];
                for (var i in data) {
                    var id = data[i]['id'];
                    var name = data[i]['name'];
                    var assignbtnDtr = mi.markLink({
                        href:
                            "javascript:RoleManager.assignSecurity('/security/to-securityAssign-dialog?type=role&id=" + id + "','" + name + "');",
                        txt: '赋权',
                        className: 'js-del-row-btn btn_operate',
                        data: [
                            {id: id}
                        ]
                    });

                    data[i]['operate'] = assignbtnDtr;
                }
                return data;
            }
        });
    })();
</script>
</body>
</html>
